package com.qf.flying;

import java.util.Random;

/**
 * Boss的制作-姚骁
 * */
public class Boss
        extends FlyObject
        implements Enemy
{
    private int Xspeed = 1;// 速度
    private int Yspeed = 2;//速度
    private int type;


    public Boss()
    {
        super();
        isAward = true;
        award = new Award();
        Random random = new Random(System.currentTimeMillis());
        award.shootSpeed = 20;
//        award.bulletSpeed = 5;
        award.life = 5;
        award.bulletNumbers = 3;
        //小概率升级子弹
        award.bulletType = random.nextInt(20) >= 18 ? 2 : 1;
        award.bulletType = random.nextInt(20) >= 19 ? 3 : award.bulletType;


        totalLife = 2000;
        life = 2000;

        image = ShootGame.boss;
        width = image.getWidth();
        height = image.getHeight();
        y = -height;
        x = (int) (Math.random() * (ShootGame.background.getWidth() - width));
        //定义奖励类型
        Random rad = new Random();
        type = rad.nextInt(2);

    }

    //控制停止往下走的变量
    private int i = 0;

    @Override
    public void step()
    {
        if (i < 200)
        {
            i++;
        }
        else if (i >= 200 && i < 1200)
        {
            i++;
            return;
        }
        y += Yspeed;
        x += Xspeed;
        if (x < 0)
        {
            Xspeed = 1;
        }

        if (x > ShootGame.background.getWidth() - width)
        {
            Xspeed = -1;
        }


    }

    @Override
    public boolean isShot(Bullet b)
    {
        return x < b.x && b.x < x + width && y < b.y && b.y < y + height;
    }


    @Override
    public int getScore()
    {
        return 50;
    }
}